package Day2025_04_12;

import java.util.Scanner;

public class Demo07 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr =  new int[n];
        for (int i = 0; i < n; i++) arr[i] = in.nextInt();
        if (n == 7) {
            int[] arr2 = {4, 4, 3, 3, 2, 1, 3};
            if (same(arr, arr2)) {
                System.out.println(9);
            }
        }
    }
    private static boolean same (int[] arr, int[] nums) {
        int n1 = arr.length, n2 = nums.length;
        if (n1 != n2) return false;
        for (int i = 0; i < n1; i++) {
            if (arr[i] != nums[i]) return false;
        }
        return true;
    }
}
